<?php
/**
 * 生成 report 
 *
 * @author <judasnow@gmail.com>
 */
class report_factory{

	private $_CI;
	public function __construct(){
	
		 $this->_CI =& get_instance();
	}

	private function rander( $temp , $info ){

		if( !empty( $info ) ){

			return $this->_CI->load->view( "report/$temp" , array( 'info'=>$info ) , TRUE );
		}

		return '';
	}

	public function create_cell( $cell_info ){

		$cell_info = json_decode( $cell_info , TRUE );

		$top_html = $this->rander( 'cell_top' , $cell_info['top_info'] );
		$headline_html = $this->rander( 'cell_headline' , $cell_info['headline_info'] );
		$describe_html = $this->rander( 'cell_describe' , $cell_info['describe_info'] );
		$key_value_html = $this->rander( 'cell_key_value' , $cell_info['key_value_info'] );

		$cell_info['html'] = $top_html . $headline_html . $key_value_html . $describe_html;

		return $this->_CI->load->view( 'report/cell' , array( 'cell_info'=>$cell_info ) , TRUE );
	}
}
